package com.fairytask.objects
{
	import com.fairytask.utils.Vec2D;
	
	import flash.display.Sprite;
	
	public class Avatar extends Sprite
	{
		public var acc:Number=0;
		protected var _forward:Boolean=false;
		public var angAcc:Number=0;
		public var point:Boolean=true;
		public var vel:Number=0;
		public var angVel:Number=0;
		protected var _right:Boolean=false;
		protected var _left:Boolean=false;
		public var ov:Vec2D;
		public var friction:Number=1;
		
		public function Avatar()
		{
			ov = new Vec2D();
			super();
		}
		
		public function clearFlags():void
		{
			_forward = false;
			_left = false;
			_right = false;
		}
		
		public function forward():void
		{
			_forward = true;
		}
		
		public function get posV():Vec2D
		{
			return new Vec2D(x, y);
		}
		
		public function left():void
		{
			_left = true;
			
		}
		
		public function update(arg1:Number):void
		{
			ov.angle = ov.angle + angVel * arg1;
			rotation = ov.angle;
			vel = vel + acc * arg1;
			var loc1:Vec2D=ov.mulNum(vel);
			x = x + loc1.x * arg1;
			y = y + loc1.y * arg1;
			
		}
		
		public function pointAt(pX:Number, pY:Number):void
		{
			var tmpVec:Vec2D=new Vec2D(pX, pY);
			rotation = ov.angle = tmpVec.subVec(posV).angle;
		}
		
		public function right():void
		{
			_right = true;
		}
	}
}